<?php

/**
 * ImageController
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class ImageController extends Zend_Controller_Action {
	/**
	 * The default action - show the home page
	 */
	public function indexAction() {
		throw new Zend_Controller_Action_Exception('Document not found', 404);
	}
	
	public function coverAction() {
		if (NULL === $id = $this->getRequest()->getParam('id')) {
			throw new Zend_Controller_Action_Exception('Document not found', 404);
		}

		MF_Main::getInstance()->Cover->getById($id)->file->Push();
		 
		 
		$this->_helper->layout->disableLayout();
	}
	
	public function captchaAction() {
		if (NULL === $file = $this->getRequest()->getParam('file')) {
			throw new Zend_Controller_Action_Exception('Document not found', 404);
		}
		
		$main = MF_Main::getInstance();
		$tmp_dir = $main->_config->general->temp_path;
		$captcha_im = $main->Utils->fixDirPath($tmp_dir).$file;
		
		if (!file_exists($captcha_im)) {
			throw new Zend_Controller_Action_Exception('Document not found', 404);
		}
		
		$this->_response->clearHeaders();
		$this->_response->setHeader('Content-type','image/png');
		
		
		$im = $main->Utils->File($captcha_im);
		$im->Push();
		$im->delete();
		$this->_helper->layout->disableLayout();
	}
	
	

}